<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

if ($_FILES["file"]["error"] > 0) {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
} else {
    //echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    //echo "Type: " . $_FILES["file"]["type"] . "<br />";
    //echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    //echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    $servername = "http://".$_SERVER['SERVER_NAME'];
    $updir = "/Upload/tinypic/";
    if (file_exists("../../Upload/tinypic/" . $_FILES["file"]["name"])) {
        echo $servername.$updir . $_FILES["file"]["name"];
    } else {
        move_uploaded_file($_FILES["file"]["tmp_name"], "../../Upload/tinypic/" . $_FILES["file"]["name"]);
        echo $servername.$updir . $_FILES["file"]["name"];
    }
}